﻿@functions{
    void BuildRibbonTab(SpreadsheetSettings settings)
    {
        settings.RibbonTabs.AddRange(SpreadsheetExtension.DefaultRibbonTabs);
        //settings.RibbonTabs[0].Visible = false;
        var group0 = settings.RibbonTabs[0].Groups.Add("文件管理");
        group0.Items.Add(new DevExpress.Web.RibbonButtonItem("FileManageLink", "报表文件管理"));
        var tab = settings.RibbonTabs.Add("数据链接");
        var group = tab.Groups.Add("单点数据");
        group.Items.Add(new DevExpress.Web.RibbonButtonItem("HourDataLink", "小时数据"));
        group.Items.Add(new DevExpress.Web.RibbonButtonItem("DayDataLink", "日数据"));
        group.Items.Add(new DevExpress.Web.RibbonButtonItem("MonthDataLink", "月数据"));
        settings.ClientSideEvents.CustomCommandExecuted = "ReportDesignerStaticClass.SpreadSheet_CuntomCommand";
    }
}
@Html.DevExpress().Spreadsheet(
    settings =>
    {
        settings.Name = "spreadsheet";
        settings.CallbackRouteValues = new { Controller = "Report", Action = "SpreadSheetDesignerPartial" };
        settings.CustomActionRouteValues = new { Controller = "Report", Action = "SpreadCalcbackCommand" };
        settings.Width = Unit.Percentage(100);
        settings.Height = Unit.Percentage(100);
        //settings.FullscreenMode = true;
        settings.ActiveTabIndex = 0;
        settings.ShowConfirmOnLosingChanges = false;
        settings.WorkDirectory = SpreadSheetViewer.Helper.DirectoryManagmentUtils.DocumentBrowsingFolderPath;
        settings.SettingsDocumentSelector.UploadSettings.Enabled = true;
        settings.RibbonMode = SpreadsheetRibbonMode.Ribbon;
        settings.PreRender += (s, _) =>
        {
            MVCxSpreadsheet spreadsheet = (MVCxSpreadsheet)s;
            //spreadsheet.Document.LoadDocument(Path.Combine(SpreadSheetViewer.Helper.DirectoryManagmentUtils.DocumentBrowsingFolderPath, "BreakevenAnalysis.xlsx"));
            spreadsheet.Document.Options.CalculationMode = DevExpress.Spreadsheet.WorkbookCalculationMode.Manual;
            Session["Spread"] = spreadsheet.Document;
        };
        BuildRibbonTab(settings);
        settings.ClientSideEvents.BeginCallback = "ReportDesignerStaticClass.OnSpreadsheetBeginCallback";
        settings.ClientSideEvents.EndCallback = "ReportDesignerStaticClass.OnSpreadsheetEndCallback";
    }
).GetHtml()